<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:a="http://xmlns.heustics.org/schema/myelin/0.1/" 
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:o="&a;Document#view"
  extension-element-prefixes="exslt"
  exclude-result-prefixes="xsl exslt a l o"
> 
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;Document#view')"/>  
  <xsl:variable name="o:actions-l10n" select="$o:l10n/l:context[@name='actions']/*"/>
  <xsl:variable name="o:container-l10n" select="$o:l10n/l:context[@name='container']/*"/>
  <xsl:variable name="o:new-actions-l10n" select="$o:l10n/l:context[@name='new-actions']/*"/>  
 
  <xsl:variable name="o:theme" select="a:get-l10n('&a;Document#view-theme')"/>
      
  <xsl:template name="a:node-action-href-ext">
    <xsl:param name="key" select="string(@key)"/>
    <xsl:param name="label" select="$o:actions-l10n[@key=$key]"/>
    <xsl:param name="href-ext"/>
    <xsl:if test="string-length($label)">
      <div class='node_action {$key}'>
        <xsl:choose>
          <xsl:when test="@selected">
            <span class="current">
              <xsl:value-of select="$label"/>
            </span>
          </xsl:when>
          <xsl:otherwise>            
            <a href='{a:format-node-action($key)}&amp;{$href-ext}'>
              <xsl:value-of select="$label"/>
            </a>
          </xsl:otherwise>
        </xsl:choose>
        <div class="spacer"/>        
      </div>
    </xsl:if>    
  </xsl:template>
  
  <xsl:template match="a:acl" mode="a:node-action" name="a:node-action">
    <xsl:param name="key" select="string(@key)"/>
    <xsl:param name="label" select="$o:actions-l10n[@key=$key]"/>
    <xsl:if test="string-length($label)">
      <div class='node_action {$key}'>
        <xsl:choose>
          <xsl:when test="@selected">
            <span class="current">
              <xsl:value-of select="$label"/>
            </span>
          </xsl:when>
          <xsl:otherwise>
            <a href='{a:format-node-action($key)}'>
              <xsl:value-of select="$label"/>
            </a>            
          </xsl:otherwise>
        </xsl:choose>
        <div class="spacer"/>    
      </div>
    </xsl:if>   
  </xsl:template> 
  
  <xsl:template match="a:acl-group[@name='new-node-types']" mode="a:node-action">
    <xsl:if test="*">
      <xsl:variable name="acls-rtf">
        <xsl:apply-templates mode="a:select-action"/>
      </xsl:variable>    
      <xsl:variable name="acls" select="exslt:node-set($acls-rtf)"/>
      <xsl:if test="$acls/*">
        <div class="acl_group">      
          <form method='POST' action="{a:format-url-action-type('new-node')}">
            <input name="init" type="hidden" value="{$o:l10n/l:gentext[@key='add']}"/>
            <select name="action" style="font-size:x-small">                   
              <xsl:copy-of select="$acls"/>
            </select>        
            <input style="font-size:x-small" name="event" type="submit" value="{$o:l10n/l:gentext[@key='add']}"/>
          </form>    
        </div>  
      </xsl:if>      
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="a:acl" mode="a:select-action" name="a:select-action"> 
    <xsl:param name="key" select="string(@key)"/>
    <xsl:param name="label" select="$o:new-actions-l10n[@key=$key]"/>   
    <xsl:if test="string-length($label)">
      <option value='{$key}'>
        <xsl:if test="@selected">
          <xsl:attribute name="selected">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$label"/>      
      </option>
    </xsl:if>    
  </xsl:template>
  
  <xsl:template match="a:modes" mode="a:main-actions">
    <xsl:param name="l10n" select="$o:l10n/*[@name='content-modes']/*"/>
    <div class="box action modes">
      <dl>
        <dt>
          <xsl:value-of select="$o:l10n/*[@key='content-modes-key']"/>
        </dt>
      </dl>
      <div class='body'>
        <div class='wrapper'>
          <xsl:apply-templates mode="a:modes">
            <xsl:with-param name="l10n" select="$l10n"/>
          </xsl:apply-templates>
        </div> 
        <div class='spacer methods-body-spacer'/>
      </div>
      <div class='spacer methods-action-spacer'/>           
    </div>
  </xsl:template> 
  
  <xsl:template match="a:mode" mode="a:modes">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='content-modes']/*"/>
    <xsl:variable name="key" select="string(@key)"/>
    
    <div class="mode">    
      <xsl:choose>
        <xsl:when test="@selected">
          <xsl:value-of select="$l10n[@key=$key]"/> 
        </xsl:when>
        <xsl:otherwise>
          <a href="{a:format-request-new-mode($key)}">
            <xsl:value-of select="$l10n[@key=$key]"/>
          </a>     
        </xsl:otherwise>
      </xsl:choose>
      <div class="spacer"/>
    </div>
  </xsl:template>
 
    
</xsl:stylesheet>

